<template>
    <div class="flex data">
        <div class="flex" v-for="item in state.datas">
            <div class="flex flex-center icon">
                <svg-icon size="20px" :icon-class="item.icon"></svg-icon>
            </div>
            <div class="flex flex-col flex-1 justify-between">
                <p>{{ item.title }}</p>
                <span>{{ item.num }}</span>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { getDataReportApi } from '@/api/b2b'

const state = reactive({
    datas:[
        {
            icon:'box-3-fill',
            title:'产品发布数',
            num:0
        },
        {
            icon:'send-plane-fill',
            title:'产品访问量',
            num:0
        },
        {
            icon:'article-fill',
            title:'文章发布数',
            num:0
        },
        {
            icon:'draft-fill',
            title:'文章访问量',
            num:0
        }
    ]
})

async function getDataReport(){
    const res = await getDataReportApi()
    state.datas[0].num = res.data[0].ProCount
    state.datas[1].num = res.data[0].ProHitNumber
    state.datas[2].num = res.data[0].ArtCount
    state.datas[3].num = res.data[0].ArtHitNumber
}

onMounted(() => {
    getDataReport()
})
</script>

<style lang="scss" scoped>
.data{
    padding: 36px 0;
    &>div{
        width:25%;
        padding: 0 0 0 40px;
        border-right:1px solid #eaeaf2;
        .icon{
            width: 46px;
            height: 46px;
            border-radius: 50%;
            margin-right: 20px;
            border:6px solid #fcdde3;
            background-color: #fb6b74;
            svg{
                color: #fff;
            }
        }
        p{
            font-size: 14px;
            color: #999999;
        }
        span{
            font-size: 24px;
            font-weight: 700;
            font-family: 'Din WEB';
        }
        &:nth-child(2){
            .icon{
                border:6px solid #fcebcd;
                background-color: #f5ad37;
            }
        }
        &:nth-child(3){
            .icon{
                border:6px solid #e0e4ff;
                background-color: #6e7bfe;
            }
        }
        &:nth-child(4){
            .icon{
                border:6px solid #fcebcd;
                background-color: #f5ad37;
            }
        }
        &:last-child{
            border-right:none;
        }
    }
}
</style>